using Headspring.Training.DataAccess.Impl;
using NHibernate;
using NHibernate.Tool.hbm2ddl;

namespace Headspring.Training.DataAccess.IntegrationTests
{
	public static class TestHelper
	{
		public static void RecreateDatabase()
		{
			HybridSessionBuilder sessionBuilder = getSessionBuilder();
			SchemaExport exporter = new SchemaExport(sessionBuilder.GetConfiguration());
			exporter.Execute(false, true, false, true);
		}

		private static HybridSessionBuilder getSessionBuilder()
		{
			return new HybridSessionBuilder();
		}

		public static void ResetSession()
		{
			HybridSessionBuilder.ResetSession();
		}

		public static void ClearTables()
		{
			ISession session = getSessionBuilder().GetSession();
			session.Delete("from WorkOrder");
			session.Delete("from Employee");
			session.Flush();
		}
	}
}